package com.mlx.meng.tool;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @description: 这个类，类似于分页插件中的PageInfo
 * @DateTime: 2021-04-16 10:55
 * @author: 蒙利幸
 * @version: 1.0
 **/
public class PageAuxiliary<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer total;

    private List<T> list;

    public PageAuxiliary(Collection<T> dataList){
        if (dataList == null || dataList.isEmpty()){
            this.total = 0;
            this.list = new ArrayList<>();
        }else {
            this.total = dataList.size();
            if (dataList instanceof List){
                this.list = (List<T>) dataList;
            }else {
                this.list = new ArrayList<>(dataList);
            }
        }
    }

    public PageAuxiliary(){
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
